/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
   $(document).ready(function(){
    loadBlogs();
    $("div.member ul li a").click(function(){
        var id=$(this).attr("id");
		$(this).css({"background-image":"url(../public/images/memberlibackground.png)","background-position":"0 -72px","background-repeat":"no-repeat","display":"block","height":"68px","padding":"0 0 0 35px","text-decoration":"none"});//点击改变背景
		var userid=$.cookies.get("userid");//取cookie
		$("ul li a[id="+userid+"]").css({"background-image":"url(../public/images/memberlibackground.png)","background-position":"0 -3px","background-repeat":"no-repeat","display":"block","height":"68px","padding":"0 0 0 35px","text-decoration":"none"});//回复激活前背景
		$.cookies.set("userid",id);
    var url="http://localhost/sina/index.php/ajax_serv";
    var dataP={
            value:id
        };
    $(".maincontent").html("<div class='loadmsg'><span>数据加载中····</span><img src='http://localhost/sina/public/images/loadimg.gif'/></div>");
	$(".loadmsg").show();
    $.get(url,dataP,function(data){
        var json=$.parseJSON(data);
		var count=json.count;
        $(".maincontent").html("");
        $(".maincontent").append(json.result);
		$('.maincontent ul li:eq('+count+')').children(".line").css("border","none");
		openat();
        });
    });
    function loadBlogs(){
        $.cookies.set("userid","1");
        var userid=$.cookies.get("userid");//取cookie
        $("ul li a[id="+userid+"]").css({"background-image":"url(../public/images/memberlibackground.png)","background-position":"0 -72px","background-repeat":"no-repeat","display":"block","height":"68px","padding":"0 0 0 35px","text-decoration":"none"});
        $(".maincontent").html("<div class='loadmsg'><span>数据加载中····</span><img src='http://localhost/sina/public/images/loadimg.gif'/></div>");
		$(".loadmsg").show();
       var url="http://localhost/sina/index.php/ajax_serv?value=1";
        $.get(url,function(data){
            var json=$.parseJSON(data);
			var count=json.count;
            $(".maincontent").html("");
            $(".maincontent").append(json.result);
			$('.maincontent ul li:eq('+count+')').children(".line").css("border","none");
			openat();
        });
    }
});
//@打开新的窗口
function openat(){
	$(".at").click(function(){
		newwindow=window.open();
		var href=$(this).attr("name");
		var url="http://localhost/sina/index.php/at_link";
		var dataP={
			name:href
			}
		$.get(url,dataP,function(data){
			var json=$.parseJSON(data);
			var msg=json.code;
			if(msg==0){
				return;
			}
			else{
			newwindow.location=json.name_link;
				}
		});
		});	
	};



